package com.ray.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ray.bean.DatatablesViewPageBean;
import com.ray.exception.ServiceException;
import com.ray.service.DeviceService;
import com.ray.service.TestService;
import com.ray.service.WeiXinService;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;
import com.ray.util.ReturnStringUtil;

@Controller
@RequestMapping("/device")
public class DeviceController {
	
	@Autowired
	DeviceService deviceService;
	
    
//	@RequestMapping("/getDeviceRealTime")
//	@ResponseBody
//	public DatatablesViewPageBean getDeviceRealTime(HttpServletRequest request) throws ServiceException{
//		Map map=RequestUtil.getRequestAllParam(request);
//		return deviceService.getDeviceRealTime(map);
//	}
	
	//查询电气数据，根据车间
	@RequestMapping("/getPowerDataOnTime")
	@ResponseBody
	public DatatablesViewPageBean getPowerDataOnTime(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return deviceService.getPowerDataOnTime(map);
	}
	
    //设置电气action
	@RequestMapping("/setPowerAction")
	@ResponseBody
	public Map setPowerAction(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		deviceService.setPowerAction(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.UPDATE_SUCCESS);
	}
	
	//设置电气车间
	@RequestMapping("/setPowerWorkShop")
	@ResponseBody
	public Map setPowerWorkShop(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		deviceService.setPowerWorkShop(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.SET_SUCCESS);
	}
	
	//设置设备设置时间段
	@RequestMapping("/setTime")
	@ResponseBody
	public Map setTime(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		deviceService.setTime(map);
		return ResponseUtil.ResponseResult(ReturnStringUtil.SET_SUCCESS);
	}
	
	
	//获取设备设置时间段
	@RequestMapping("/getPowerTimeByPowerId")
	@ResponseBody
	public Map getPowerTimeByPowerId(HttpServletRequest request) throws ServiceException{
		Map map=RequestUtil.getRequestAllParam(request);
		return ResponseUtil.ResponseResult(deviceService.getPowerTimeByPowerId(map));
	}
	
	
	

}
